﻿using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using MyFloridaHouse.DataAccess.Extensions;
using MyFloridaHouse.libSvDTO;

namespace MyFloridaHouse.DataAccess
{
	/// <summary>
	/// Data Aaccess Layer Census Data methods for American Community Survey data.
	/// </summary>
    public partial class DAL_CensusData
    {

		/// <summary>
		/// Gets the ACS (American Community Survey) report definition.
		/// </summary>
		/// <returns>List of <see cref="ACSDistrictSummaryReportDefinitionDTO"/></returns>
		/// <remarks>SPROC: usp_GetACSReportDefinition</remarks>
        public List<ACSDistrictSummaryReportDefinitionDTO> GetACSReportDefinition()
        {
            var itemList = new List<ACSDistrictSummaryReportDefinitionDTO>();

            string storedProcedureName = "usp_tl10GetACSReportDefinition10";
           // string storedProcedureName = "usp_moGetRegions";

            using (SqlConnection db = Connect())
            {
                SqlCommand StoredProcedureCommand = new SqlCommand(storedProcedureName, db);
                StoredProcedureCommand.CommandType = CommandType.StoredProcedure;

                db.Open();
                using (SqlDataReader rdr = StoredProcedureCommand.ExecuteReader())
                {
                    while (rdr.Read())
                    {
                        itemList.Add(ACSDistrictSummaryReportDefinitionDTODataContract.DataContract(rdr));
                    }
                }
            }

            //Database db = Connect();
            ////DbCommand dbCommand = db.GetStoredProcCommand("usp_GetACSReportDefinition");
            //DbCommand dbCommand = db.GetStoredProcCommand("usp_tl10GetACSReportDefinition10");
            //dbCommand.CommandTimeout = 60000;
            //using (IDataReader rdr = db.ExecuteReader(dbCommand))
            //{
            //    while (rdr.Read())
            //    {
            //        itemList.Add(ACSDistrictSummaryReportDefinitionDTODataContract.DataContract(rdr));
            //    }
            //}
            return itemList;
        }


    }
}
